<template>
	<view class="content">
		<swiper class="swiper" :indicator-dots="indicatorDots" indicator-color="#eeeeee" indicator-active-color="#5CD694"
		 :autoplay="autoplay" :duration="duration" :current="index" @change="change">
			<swiper-item v-for="(item,index) in guideData" :key="index">
				<view class="swiper-item">
					<view class="swiper-item-img">
						<image :src="item.img" lazy-load mode="aspectFill"></image>
					</view>
					<view class="title">
						<text>{{item.big_text||''}}</text>
						<text>{{item.small_text||''}}</text>
					</view>
					<view class="experience" v-if="index == guideData.length - 1" @tap="launchFlag()">{{experience}}</view>
				</view>
			</swiper-item>
		</swiper>
		<uni-popup ref="popup" :maskClick="false" type="center">
			<view class="screenBox">
				<view class="contents">
					<text class="title">服务协议和隐私政策</text>
					<view class="cont">
						请你务必审慎阅读、充分理解"服务协议"和"隐私政策"各条款,包括但不限于：为了向你提供即时通讯、内容分享等服务，我们需要手机你的设备信息、操作日志等个人信息。你可以在"设置"中查看、变更、删除个人信息并管理你的授权。你可阅读<text
						 class="a" @tap="goRule(7,'服务协议')">《服务协议》</text>和<text class="a" @tap="goRule(10,'隐私政策')">《隐私政策》</text>了解详细信息。如你同意，请点击"同意"开始接受我们的服务。
					</view>
				</view>
				<view class="btngroup">
					<view class="a" @tap="quit">暂不使用</view>
					<view class="a b" @tap="close">同意</view>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import {
		guidePage
	} from "@/api/app.js"
	import uniPopup from '@/components/uni-popup/uni-popup.vue'
	export default {
		components: {
			uniPopup
		},
		data() {
			return {
				indicatorDots: true,
				autoplay: false,
				duration: 500,
				experience: '立即体验',
				index: 0,
				guideData: []
			}
		},
		onLoad() {
			guidePage().then(res => {
				switch (uni.getSystemInfoSync().platform) {
				
					case 'android':
				
						this.$refs.popup.open()
				
						break;
				
				}
				
				this.guideData = res.data.roll
			})
		},
		methods: {
			launchFlag: function() {
				uni.setStorageSync('launchFlag', true)
				uni.redirectTo({
					url: '/pages/index/index'
				})
			},
			change(e) {
				let len = this.guideData.length
				if (e.target.current == len - 1) {
					this.indicatorDots = false
				} else {
					this.indicatorDots = true
				}
			},
			goRule(id, name) {
				uni.navigateTo({
					url: `/pages/center/help/rulesDetail?id=${id}&tit=${name}`
				})
			},
			quit() {
				// #ifdef APP-PLUS  
				plus.runtime.quit();  
				// #endif
			},
			close() {
				this.$refs.popup.close()
			}
		}
	}
</script>
<style lang="scss" scoped>
	page,
	.content {
		width: 100vw;
		height: 100vh;
		padding: 0;

		.swiper {
			width: 100vw;
			height: 100vh;

			.swiper-item {
				position: relative;

				.swiper-item-img {
					image {
						width: 100vw;
						height: 100vh;
					}
				}

				.title {
					position: absolute;
					width: 100vw;
					bottom: 16vh;
					display: flex;
					flex-direction: column;
					align-items: center;
					color: rgba(51, 51, 51, 1);

					text:nth-of-type(1) {
						display: block;
						font-size: 80rpx;
						font-weight: 500;
					}

					text:nth-of-type(2) {
						margin-top: 20rpx;
						font-size: 40rpx;
					}
				}
			}

			.experience {
				position: absolute;
				left: 150rpx;
				bottom: 7vh;
				width: 450rpx;
				height: 90rpx;
				border: 2rpx solid rgba(62, 200, 126, 1);
				border-radius: 45rpx;
				text-align: center;
				line-height: 90rpx;
				color: #52CC8C;
			}
		}
	}
	.screenBox{
		width: 560rpx;
		background: #fff;
		border-radius: 10rpx;
		.contents{
			padding: 30rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
			.title{
				font-size: 36rpx;
				margin-bottom: 20rpx;
			}
			.cont{
				font-size: 28rpx;
				color: #444;
				text-align: justify;
				.a{
					color: $theme-color;
				}
			}
		}
		.btngroup{
			border-top: 1rpx solid #f5f5f5;
			padding: 30rpx;
			display: flex;
			font-size: 38rpx;
			color: #333;
			.a{
				width: 50%;
				text-align: center;
				height: 80rpx;
				line-height: 80rpx;
			}
			.b{
				border-left: 1rpx #f5f5f5 solid;
				color: $theme-color;
			}
		}
	}

	/deep/ .uni-swiper-dots {
		bottom: calc(3.5vh + 45rpx) !important;
	}
</style>
